#include <music.h>

void playNote(int pin, int freq, int duration)
{
	for (long i = 0; i < duration * 1000L; i += freq * 2)
	{
		digitalWrite(pin, HIGH);
		delayMicroseconds(freq);
		digitalWrite(pin, LOW);
		delayMicroseconds(freq);
	}
}

void playSong(int pin, int song, int beats, int length, int tempo)
{
	for (int i = 0;i<length;i++)
	{
		if (song[i] == -1)
			delay(beats[i] * tempo) // rest
		else
			playNote(pin, song[i], beats[i] * tempo);
	}
}